package com.huangkailong.designpattern.flyweight;

import java.util.Random;

/**
 * 火车票.
 *
 * @author huangkl
 * @since 1.0.0
 */
public class TrainTicket implements ITicket {
    /**
     * 出发地.
     */
    private final String from;
    /**
     * 目的地.
     */
    private final String to;

    public TrainTicket(String from, String to) {
        this.from = from;
        this.to = to;
    }

    @Override
    public void showInfo(String seatType) {
        Integer price = new Random().nextInt(1000);
        System.out.printf("%s-->%s %s %d元\n", from, to, seatType, price);
    }
}
